home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / Stonewall.dxr / Internal_5_tableau cards.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  9.5 KB  |  279 lines

  1. property spriteNum, row, motion, location, fp
  2. global tableau, stock, equal, getlist, godlist, reserve, currentsel, dimpos, extras, points, foundation
  3.  
  4. on beginSprite me
  5.   row = determinerow()
  6.   location = sprite(spriteNum).loc
  7.   if not objectp(tableau[row]) then
  8.     tableau.addProp(row, new(script("card pile")))
  9.     if voidp(reserve[row]) then
  10.       reserve.addProp(row, [])
  11.     end if
  12.     repeat with i = 1 to 3
  13.       reserve[row].add(stock.cards[1].rank & "_" & stock.cards[1].suit)
  14.       stock.cards.deleteAt(1)
  15.     end repeat
  16.   end if
  17.   if tableau[row].getcardcount() < 3 then
  18.     if (spriteNum mod 2) = 0 then
  19.       sprite(spriteNum).member = member(stock.cards[1].rank & "_" & stock.cards[1].suit, "playing cards")
  20.       stock.cards.deleteAt(1)
  21.       tableau[row].addCard(spriteNum)
  22.     else
  23.       sprite(spriteNum).member = member("backofcard", "playing cards")
  24.     end if
  25.   end if
  26.   candd = [#one: 12, #two: 28, #thr: 44, #fou: 60, #fiv: 76, #six: 92]
  27.   fp = candd[row]
  28. end
  29.  
  30. on determinerow me
  31.   if (spriteNum >= 12) and (spriteNum <= 25) then
  32.     return #one
  33.   else
  34.     if (spriteNum >= 28) and (spriteNum <= 41) then
  35.       return #two
  36.     else
  37.       if (spriteNum >= 44) and (spriteNum <= 57) then
  38.         return #thr
  39.       else
  40.         if (spriteNum >= 60) and (spriteNum <= 73) then
  41.           return #fou
  42.         else
  43.           if (spriteNum >= 76) and (spriteNum <= 89) then
  44.             return #fiv
  45.           else
  46.             if (spriteNum >= 92) and (spriteNum <= 105) then
  47.               return #six
  48.             end if
  49.           end if
  50.         end if
  51.       end if
  52.     end if
  53.   end if
  54. end
  55.  
  56. on mouseDown me
  57.   if sprite(spriteNum).member <> member("empty", "playing cards") then
  58.     puppetSound(3, member("pick card", "100GPak Generic SFX"))
  59.     if spriteNum = tableau[row].getlastcard().spnum then
  60.       sprite(spriteNum).locZ = spriteNum + 1000
  61.       getlist = tableau[row]
  62.       motion = timeout(string(spriteNum)).new(5, #moving, me)
  63.       if reserve[row].count > 0 then
  64.         sprite(tableau[row].cards[1].spnum - 1).member = member("backofcard", "playing cards")
  65.       else
  66.         sprite(tableau[row].cards[1].spnum - 1).member = member("empty", "playing cards")
  67.       end if
  68.     else
  69.       if reserve[row].count > 0 then
  70.         sprite(tableau[row].cards[1].spnum - 1).member = member("backofcard", "playing cards")
  71.       else
  72.         sprite(tableau[row].cards[1].spnum - 1).member = member("empty", "playing cards")
  73.       end if
  74.       if sprite(spriteNum).member.name <> "backofcard" then
  75.         runcheck()
  76.       end if
  77.     end if
  78.   else
  79.     sendSprite(spriteNum - 1, #mouseDown)
  80.   end if
  81. end
  82.  
  83. on moving me
  84.   if the mouseDown then
  85.     sprite(spriteNum).loc = the mouseLoc
  86.   else
  87.     if the mouseUp then
  88.       motion.forget()
  89.       sprite(spriteNum).locZ = spriteNum
  90.       abort()
  91.     end if
  92.   end if
  93. end
  94.  
  95. on mouseUp me
  96.   if equal then
  97.     puppetSound(3, member("pick card", "100GPak Generic SFX"))
  98.     if extras.count = 0 then
  99.       sprite(currentsel).member = member(sprite(spriteNum).member.name, "playing cards")
  100.       godlist.addCard(currentsel)
  101.       tableau[row].cards.deleteOne(tableau[row].getlastcard())
  102.       sprite(spriteNum).member = member("empty", "playing cards")
  103.       sprite(spriteNum).loc = location
  104.     else
  105.       if extras.count > 0 then
  106.         extras.sort()
  107.         repeat with i = 0 to extras.count - 1
  108.           sprite(currentsel + i).member = member(sprite(the clickOn + i).member.name, "playing cards")
  109.           sprite(the clickOn + i).member = member("empty", "playing cards")
  110.           godlist.addCard(currentsel + i)
  111.           tableau[row].cards.deleteAt(tableau[row].getcardcount())
  112.           sprite(the clickOn + i).loc = sprite(the clickOn + i).location
  113.         end repeat
  114.         if tableau[row].getcardcount() > 0 then
  115.           if sprite(spriteNum - 1).member.name = "backofcard" then
  116.             sprite(spriteNum - 1).member = member(reserve[row][1], "playing cards")
  117.             reserve[row].deleteAt(1)
  118.             tableau[row].addCard(spriteNum - 1)
  119.           end if
  120.         end if
  121.       end if
  122.     end if
  123.     if tableau[row].getcardcount() > 0 then
  124.       if extras.count = 0 then
  125.         if sprite(spriteNum - 1).member.name = "backofcard" then
  126.           sprite(spriteNum - 1).member = member(reserve[row][1], "playing cards")
  127.           reserve[row].deleteAt(1)
  128.           tableau[row].addCard(spriteNum - 1)
  129.         end if
  130.       else
  131.         if extras.count > 0 then
  132.           put the clickOn
  133.           if sprite(the clickOn - 1).member.name = "backofcard" then
  134.             sprite(the clickOn - 1).member = member(reserve[row][1], "playing cards")
  135.             reserve[row].deleteAt(1)
  136.             tableau[row].addCard(the clickOn - 1)
  137.           end if
  138.         end if
  139.       end if
  140.     end if
  141.     extras.deleteAll()
  142.     getlist = VOID
  143.     godlist = VOID
  144.     equal = 0
  145.     if tableau[row].getcardcount() = 0 then
  146.       if reserve[row].count() > 0 then
  147.         sprite(fp).member = member(reserve[row][1], "playing cards")
  148.         reserve[row].deleteAt(1)
  149.         tableau[row].addCard(fp)
  150.       else
  151.         sprite(fp).member = member("empty", "playing cards")
  152.       end if
  153.     end if
  154.     if objectp(foundation[sprite(currentsel).row]) then
  155.       points = points + 10
  156.     end if
  157.     checkwin()
  158.     repeat with u in [26, 42, 58, 74, 90, 106]
  159.       if tableau[sprite(u).row].getcardcount() > 0 then
  160.         sprite(u).loc = sprite(tableau[sprite(u).row].getlastcard().spnum).location
  161.         next repeat
  162.       end if
  163.       sprite(u).loc = sprite(u).location
  164.     end repeat
  165.     currentsel = 0
  166.   else
  167.     if not equal then
  168.       puppetSound(3, member("drop card", "100GPak Generic SFX"))
  169.       sprite(spriteNum).loc = location
  170.       getlist = VOID
  171.       if extras > 0 then
  172.         repeat with i = 1 to extras.count
  173.           sprite(extras[i]).loc = sprite(extras[i]).location
  174.         end repeat
  175.         extras.deleteAll()
  176.       end if
  177.     end if
  178.   end if
  179.   if tableau[row].getcardcount() = 0 then
  180.     sprite(fp - 1).member = member("empty", "playing cards")
  181.   end if
  182.   repeat with u in [26, 42, 58, 74, 90, 106]
  183.     if tableau[sprite(u).row].getcardcount() > 0 then
  184.       sprite(u).loc = sprite(tableau[sprite(u).row].getlastcard().spnum).location
  185.       next repeat
  186.     end if
  187.     sprite(u).loc = sprite(u).location
  188.   end repeat
  189. end
  190.  
  191. on runcheck me
  192.   ass = 0
  193.   repeat with i = 1 to tableau[row].getcardcount()
  194.     if tableau[row].cards[i].spnum = spriteNum then
  195.       ss = i
  196.       dimpos = i
  197.       exit repeat
  198.     end if
  199.   end repeat
  200.   tt = ss + 1
  201.   repeat with ret = tt to tableau[row].getcardcount()
  202.     if tableau[row].cards[ret].suitcolor = tableau[row].cards[ret - 1].suitcolor then
  203.       exit repeat
  204.     end if
  205.     if tableau[row].cards[ret].rankvalue <> (tableau[row].cards[ret - 1].rankvalue - 1) then
  206.       exit repeat
  207.     end if
  208.     if ret <> tableau[row].getcardcount() then
  209.       next repeat
  210.     end if
  211.     ass = 1
  212.   end repeat
  213.   if ass then
  214.     getlist = tableau[sprite(tableau[row].cards[i].spnum).row]
  215.     sprite(tableau[row].cards[ss].spnum).locZ = tableau[row].cards[ss].spnum + 1000
  216.     sprite(tableau[row].cards[ss].spnum).motion = timeout(string(row) && string(spriteNum)).new(5, #moving, sprite(tableau[row].cards[ss].spnum))
  217.     extras.add(spriteNum)
  218.     repeat with ret = tt to tableau[row].getcardcount()
  219.       sprite(tableau[row].cards[ret].spnum).locZ = tableau[row].cards[ret].spnum + 1000
  220.       sprite(tableau[row].cards[ret].spnum).motion = timeout(string(row) && string(tableau[row].cards[ret].spnum)).new(1, #keepintouch, sprite(tableau[row].cards[ret].spnum))
  221.       extras.add(tableau[row].cards[ret].spnum)
  222.     end repeat
  223.   end if
  224.   repeat with u in [26, 42, 58, 74, 90, 106]
  225.     if tableau[sprite(u).row].getcardcount() = 0 then
  226.       temp = [12, 28, 44, 60, 76, 92]
  227.       temp2 = [26, 42, 58, 74, 90, 106]
  228.       ass = temp[temp2.findPos(u)]
  229.       sprite(u).loc = sprite(ass).location
  230.       next repeat
  231.     end if
  232.     sprite(u).loc = tableau[sprite(u).row].getlastcard().location
  233.   end repeat
  234. end
  235.  
  236. on keepintouch me
  237.   if the mouseDown then
  238.     sprite(spriteNum).loc = point(the mouseH, sprite(spriteNum - 1).locV + 25)
  239.   else
  240.     if the mouseUp then
  241.       sprite(spriteNum).locZ = spriteNum
  242.       motion.forget()
  243.       abort()
  244.     end if
  245.   end if
  246. end
  247.  
  248. on backCardEQ me
  249.   if spriteNum <> fp then
  250.     if (sprite(spriteNum - 1).member.name <> "backofcard") and (sprite(spriteNum - 1).member.name <> "empty") then
  251.       if (getValue(sprite(spriteNum).member.name) = (getValue(sprite(spriteNum - 1).member.name) - 1)) and (getSuitCo(sprite(spriteNum).member.name) <> getSuitCo(sprite(spriteNum - 1).member.name)) then
  252.         repeat with shit = spriteNum - 1 to spriteNum - 1
  253.           repeat with cakes = 1 to tableau.count
  254.             if tableau[cakes].getcardcount() = 0 then
  255.               next repeat
  256.             end if
  257.             if (getValue(sprite(shit).member.name) = (getValue(sprite(tableau[cakes].getlastcard().spnum).member.name) - 1)) and (getSuitCo(sprite(shit).member.name) <> getSuitCo(sprite(tableau[cakes].getlastcard().spnum).member.name)) and not getduplicateme(tableau[cakes].getlastcard().spnum) then
  258.               return 1
  259.               exit
  260.             end if
  261.           end repeat
  262.         end repeat
  263.       else
  264.         sendSprite(spriteNum - 1, #backCardEQ)
  265.       end if
  266.     end if
  267.   end if
  268.   return 0
  269. end
  270.  
  271. on getduplicateme me, argu
  272.   if (sprite(spriteNum - 1).member.name <> "empty") and (sprite(spriteNum - 1).member.name <> "backofcard") then
  273.     if (getValue(sprite(spriteNum - 1).member.name) = getValue(sprite(argu).member.name)) and (getSuitCo(sprite(spriteNum - 1).member.name) = getSuitCo(sprite(argu).member.name)) then
  274.       return 1
  275.     end if
  276.   end if
  277.   return 0
  278. end
  279.